<Kitchen bind:this={kitchen} dismiss$tag="svg" dismiss$viewBox="0 0 24 24">
  {#snippet dismiss()}
    <path fill="currentColor" d={mdiCloseCircle} />
  {/snippet}
</Kitchen>

<Button onclick={pushToKitchen}><Label>Push a New Snackbar</Label></Button>

<pre class="status">Closed Reason: {reason}</pre>
<pre class="status">Action: {action}</pre>

<script module lang="ts">
  let counter = 0;
</script>

<script lang="ts">
  import { mdiCloseCircle } from '@mdi/js';
  import Kitchen from '@smui/snackbar/kitchen';
  import Button, { Label } from '@smui/button';

  let kitchen: Kitchen<undefined, 'svg'>;
  let reason = $state('nothing yet');
  let action = $state('nothing yet');

  function pushToKitchen() {
    kitchen.push({
      props: {
        variant: 'stacked',
      },
      label:
        "This is a snackbar generated by the custom icon kitchen. Here's a counter: " +
        ++counter,
      actions: [
        {
          onClick: () => (action = 'Something'),
          text: 'Something',
        },
        {
          onClick: () => (action = 'Another'),
          text: 'Another',
        },
      ],
      dismissButton: true,
      onDismiss: () => (action = 'Dismissed'),
      onClose: (e) => {
        reason = e.detail.reason ?? 'Undefined.';
      },
    });
  }
</script>
